// components/radioGroup/radioGroup.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    options: {
      type: null
    },
    custom: {
      type: Boolean,
      value: false
    },
    placeholder: {
      type: String
    },
    type:null,
    types:{
      type:String
    },
    initvalue:{
      type:null
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    value: '',
    checked: false
  },

  /**
   * 组件的方法列表
   */
  ready(){
    console.log(this.data.initvalue);
  },
  methods: {
    bindChange(e) {
      let _options = this.data.options.map((item) => {
        if (item.label == e.detail.label) {
          item.checked = true
        } else {
          item.checked = false
        }
        return item
      })
      this.setData({
        options: _options,
        value: e.detail.value,
        checked: false
      })
      this.triggerEvent('change', {
        value: e.detail.value,
        label:e.detail.label
      })
    },
    bindChangeInputRadio(e) {
      this.setData({
        options: this.data.options.map((item) => {
          item.checked = false
          return item
        }),
        checked: true
      })
      this.triggerEvent('change', {
        value: e.detail.value
      })
    }
  },
})